using UnityEngine;

namespace AK.R2D.Utility.Singleton
{
    public abstract class SoSingleton<T> : ScriptableObject where T : ScriptableObject
    {
        private static T instance;

        public static T Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = Resources.Load<T>(typeof(T).Name);
                    if (instance == null)
                    {
                        Debug.LogError($"Singleton ScriptableObject {typeof(T)} not found in Resources.");
                    }
                }
                return instance;
            }
        }
    }
}
